package com.zx.kitchen.index.common.base;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

public abstract class ABaseFragmentPager<T> extends FragmentPagerAdapter {

    private List<T> data;

    public ABaseFragmentPager(List<T> data, FragmentManager fm) {
        super(fm);
        this.data = data;
    }

    @Override
    public int getCount() {
        if (null != data) {
            return data.size();
        }
        return 0;
    }

    @Override
    public Fragment getItem(int arg0) {
        return getItem(arg0, data.get(arg0));
    }

    public abstract Fragment getItem(int position, T data);

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    public List<T> getData() {
        return data;
    }

}
